import request from '@/utlits/request'
import {setStorageSync} from '@/utlits/myStorageSycn.js'


const state = {
	bannerData: []
}

const getters = {
	bannerData: state => state.bannerData
}

const actions = {
	async GETBANNER({commit}) {
		await request.request({url:'/banner'}).then(res => {
			let {
				code,
				banners
			} = res;
			if (code === 200) {
				commit('SETBANNERDATA', banners)
				setStorageSync(JSON.stringify(banners), 'bannerList')
			}
		})
	}
}

const mutations = {
	SETBANNERDATA(state, d) {
		state.bannerData = d
	}
}

export default {
	state,
	getters,
	actions,
	mutations,
}
